//
//  Person.m
//  OC02实例变量可见度_方法
//
//  Created by dllo on 16/2/25.
//  Copyright © 2016年 APON. All rights reserved.
//

#import "Person.h"

@implementation Person
#pragma mark - 重写 init:
- (instancetype)init
{    //1.调用父类的 init 方法 self 指对象本身.
    self = [super init];
    //当 self 指针不为空,再进行赋值
    if (self)
    {
        //2.给某个实际变量赋值
        _age = 20;
    }
    return self;
    
}

#pragma mark - setter getter;

/** 需求:通过一个方法,对_ name 实例变量赋值 */
- (void)setName:(NSString *)name
{
    _name = name;
}
/** 需求:通过一个方法,取出_name实例变量值*/
- (NSString *)name
{
    return _name;
}

#pragma mark - other;
/** 自定义初始化方法 */
- (instancetype)initWithName:(NSString *)name
{
   self = [super init];
    if (self)
    {
        _name = name;
    }
    return self;
}
- (instancetype)initWithName:(NSString *)name sex:(NSString *)sex age:(NSInteger)age
{
    self = [super init];
    if (self)
    {
        _name = name;
        _sex = sex;
        _age = age;
        
    }
    return self;
}





- (void)sayHi
{
    NSLog(@"name:%@, sex:%@, age:%ld", _name, _sex, _age);
}
- (void)name:(NSString *)name sex:(NSString *)sex age:(NSInteger)age
{
    _name = name;
    _sex = sex;
    _age = age;
}
/** 构造器 */
+ (instancetype)person
{
    /** alloc */
    Person *per1 = [[Person alloc] init];
    /** 返回对象 */
    return per1;

}

@end
